package com.zy.user.controller;

import com.alibaba.fastjson.JSON;
import com.zy.servicefeign.feign.OrderFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * description
 *
 * @author ZY
 * @date 2021年01月22日 12:48
 **/
@Slf4j
@RestController
@RequestMapping("/user")
public class TestUserController {

    @Resource
    private OrderFeign orderFeign;

    @GetMapping("/test1")
    public String test1() {
        System.out.println("用户模块通过网关调用订单模块接口，开始");
        String s = orderFeign.test2();
        System.out.println("用户模块通过网关调用订单模块接口，结束，结果：" + s);

        return "【service-module-user -> service-module-order】 通过网关调用成功";
    }

    @GetMapping("/test2")
    public String test2() {
        System.out.println("订单模块通过网关调用用户模块服务成功");
        return "订单模块通过网关调用用户模块服务成功";
    }

    @GetMapping("/getUserInfo")
    public Map<String, Object> getUserInfo(Map<String, Object> params) {
        log.info("获取用户信息入参：{}", JSON.toJSONString(params));
        Map<String, Object> retMap = new HashMap<>(3);
        retMap.put("userId", "retxxxxx");
        retMap.put("username", "赵老二");
        retMap.put("address", "广东深圳");
        return retMap;
    }

}
